package com.dt76.smallloanbackendservice.controller.lhuaw;


import com.dt76.smallloanbackendservice.pojo.lhuaw.TextMessage;
import com.dt76.smallloanbackendservice.service.lhuaw.TextMessageService;
import com.dt76.smallloanbackendservice.utils.Page;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping("/lhuaw")
public class TextMessageController {
    @Resource
    private TextMessageService textMessageService;

    @RequestMapping("/getAllText")
    @ResponseBody
    public List<TextMessage> getAllText(){
        return textMessageService.getAllText();
    }

    @RequestMapping("/qryConditionPageAllText")
    @ResponseBody
    public Page qryConditionPageAllText(@RequestParam("pageIndex")  int pageIndex,
                                    @RequestParam("tPublisher") String tPublisher){
        System.out.println("成功调用远程");
        return textMessageService.qryConditionPageAllText(pageIndex, tPublisher);
    }
//删除
    @RequestMapping("/deleteText")
    @ResponseBody
    public Result deleteText(@RequestParam("tId")int tId){
        System.out.println("成功调用删除方法，TextMessageService.deleteText>>>>>>>>");
        try {
            textMessageService.deleteText(tId);
            return new Result(true,"删除成功>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>");
        }
    }

}
